package com.ylbh.modules.member.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ylbh.common.pojo.member.dto.GoodsBrowseDTO;
import com.ylbh.common.pojo.member.vo.MemberVO;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.pojo.member.vo.ShoppingGoodsBrowseVO;
import com.ylbh.modules.member.mapper.BrowseMapper;
import com.ylbh.modules.member.mapper.MemberMapper;
import com.ylbh.modules.member.service.ShoppingBrowseService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: WJC
 * @date: 2019/11/19 18:27
 * 会员分析
 */
@Service
public class ShoppingBrowseServiceImpl implements ShoppingBrowseService{

    @Autowired
    private BrowseMapper browseMapper;

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public List<ShoppingGoodsBrowseVO> getShoppingBrowseById(String id) {
        List<ShoppingGoodsBrowseVO> list = browseMapper.selectBrowseListById(id);
        for (ShoppingGoodsBrowseVO browse : list) {
            //根据ID查找设置用户名称
            if (StringUtils.isNotBlank(browse.getBrowseUserId().toString())){
                MemberVO user = memberMapper.getByUserId(Long.valueOf(browse.getBrowseUserId()));
                browse.setWw(user.getWw());
            }
            //根据ID查找设置商铺名称
            if(null != browse.getStoreId()) {
                MemberVO store = memberMapper.getByUserId(Long.valueOf(browse.getStoreId()));
                browse.setStoreName(store.getTrueName());
            }
        }
        return list;
    }
}
